<template>
  <div>
    <el-table :data="FYGLList" border :header-cell-style="{ background: '#eef1f6' }">
      <el-table-column type="index" label="序号" width="50">
      </el-table-column>
    <el-table-column
      label="审批状态"
      prop="status"
      :formatter="formatterSPstatus"
      >
    </el-table-column>
    <el-table-column
      label="部门名称"
      prop="department_name">
    </el-table-column>
    <el-table-column
      label="单据ID"
      prop="invoices_no">
    </el-table-column>
    <el-table-column
      label="单据日期" sortable width="105"
      prop="date">
    </el-table-column>
    <el-table-column
      label="购销类型"
      prop="direction"
      :formatter="formatterDirection">
    </el-table-column>
     <el-table-column
      label="客商"
      prop="customer_name">
    </el-table-column>
    <el-table-column
      label="原币币种"
      prop="currency_name">
    </el-table-column>
     <el-table-column
      label="原币金额"
      prop="original_price">
    </el-table-column>
    <el-table-column
      label="汇率"
      prop="exchange_rate">
    </el-table-column>
    <el-table-column
      label="本币金额"
      prop="currency_price">
    </el-table-column>
    <el-table-column
      label="期初标识"
      prop="begin_flag"
      :formatter="formatterQC">
    </el-table-column>
    <el-table-column
      label="费用类型"
      prop="cap_type_all">
    </el-table-column>
    <el-table-column
      label="已匹配金额" width="100"
      prop="matched_price">
    </el-table-column>
    <el-table-column
      label="未匹配金额" width="100"
      prop="unmatched_price">
    </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { conspotCap, conCurrency } from '../../../../../api/url_lcc';
export default {
  //期初开账-现货资金
  name: "cashMoney",
  data() {
    return {
       FYGLForm:{
          page: 1, //当前页
          pageSize: 20,
          totalPage: 1,
          begin_flag:"1",
          "type":"cap",
          "department": "", 
          "customer":  "",  
          "direction": "",  
          "status": "",     
          "startDate": "",  
          "endDate": "",	
          },
        FYGLList: [],
    };
  },
  created() {
    this.getData();
  },
  methods: {
  //  审批状态
  formatterSPstatus(row, column) {
         if (row.status == "0") {
             return '草拟';
         } else if (row.status == "1") {
             return '审核中';
         } else if (row.status == "4") {
             return '已通过';
         } else if (row.status == "2") {
             return '已驳回';
         } else if (row.status == "3") {
             return '已退审';
         } 
     },
    //  费用类型
    formatterCost(row, column) {
      if (row.cap_type_all == "0") {
             return '货款';
         } else if (row.cap_type_all == "1") {
             return '资金划拨';
         } else if (row.cap_type_all == "2") {
             return '利息';
         } else if (row.cap_type_all == "3") {
             return '运输费';
         } else if (row.cap_type_all == "4") {
             return '装卸费';
         } else if (row.cap_type_all == "5") {
             return '仓储费';
         } else if (row.cap_type_all == "6") {
             return '保险费';
         } else if (row.cap_type_all == "7") {
             return '质押费';
         } else if (row.cap_type_all == "8") {
             return '清关费';
         } 
     },
     // 是否红冲
   formatterRD(row,column){
       return row.status = "0"?'否':'是'
   },
    // 敞口类型逐笔，净敞口
    formatterET(row, column) {
         if (row.exp_type == "0") {
             return '逐笔';
         } else if (row.exp_type == "1") {
             return '净敞口';
         } 
     },
    //  购销类型
    formatterDirection(row, column) {
         if (row.direction == "0") {
             return '采购';
         } else if (row.direction == "1") {
             return '销售';
         } 
     },
       // 期初标志
    formatterQC(row,column){
        // return row.begin_flag = "0"?'否':'是'
         if (row.begin_flag == "0") {
             return '否';
         } else if (row.begin_flag == "1") {
             return '是';
         } 
    },
      // 查询币种
      handle_currencyChange(){
         let params = {
              "name": "",
          };
          conCurrency(params).then(res => {
              if (res.errcode == "1") {
                 this.selectCurrencyList = []
                  var data1 = res.result
                  console.log(902,)
                for (var i = 0; i < data1.length; i++) {
                        this.selectCurrencyList[i] = {
                            currency: data1[i]['id'],
                            name: data1[i]['name']
                        };
                    }
              } else {
                  this.$message.error(res.msg);
              }
          });
      },
     // 每页数
    handleSizeChange(val) {
      this.FYGLForm.pageSize = val;
      this.FYGLForm.page = 1;
     this.FYGLChange1();
    },
    // 当前页
    handleCurrentChange(val) {
      console.log(val);
      this.FYGLForm.page = val;
      this.FYGLChange1();
    },
    // 查询
     FYGLChange(){
      this.FYGLForm.page = 1;
      this.FYGLChange1();
      this.handle_currencyChange()
    },
    FYGLChange1(){
        conspotCap(this.FYGLForm).then(res => {
            if (res.errcode == "1") {
                this.FYGLList = []
                var data = res.result.results
                 this.FYGLForm.totalPage = res.result.count;
                for (var i = 0; i < data.length; i++) {
                  this.FYGLList = data
                  console.log(12,data)
              }
             }else{
                this.$message.error(res.msg);
            }
        });
    },
  },
  mounted() {
    this.FYGLChange();
   }
};
</script>
